import request from './network.js'

// let userInfoData = my.getStorageSync({ key: 'userInfo' });
// let header = {
//   'content-type': 'application/x-www-form-urlencoded',
//   'Authorization': userInfoData.data.token
// };

const headers = {'content-type': 'application/x-www-form-urlencoded'};

// 获取用户id
export function authorization(prams) {
  return request({
    url: '/shopUser/authorization',
    headers: headers,
    method: 'POST',
    data: {"data": prams}
  })
}

// 新车业务获取用户id
export function authorizationxc(prams) {
  return request({
    url: '/newcarstaging/authorizationxc',
    headers: headers,
    method: 'POST',
    data: {"data": prams}
  })
}

// 推荐列表
export function getRecommendCarList() {
  return request({
    url: '/car/getRecommendCarList',
    headers: headers,
    method: 'POST'
  })
}

// banner图片
export function getAdvertList(prams) {
  return request({
    url: '/advert/getAdvertList',
    headers: headers,
    method: 'POST',
    data: {"data": prams}
  })
}

/**6.获取商品列表 */
export function GoodsList(prams){
    return request({
		type: 'sc',
		url:'/goods/getGoodsList',
		headers:headers,
		method:'POST',
		data:{"data":prams}
	})
}
/**7.获取商品详情 */
export function GoodsDetails(prams){
    return request({
		type: 'sc',
		url:'/goods/getGoodsDetails',
		headers:headers,
		method:'POST',
		data:{"data":prams}
	})
}
/**8.商品下单 */
export function saveGoodsOrder(prams){
    return request({
		type: 'sc',
		url:'/carOrder/saveGoodsOrder',
		headers:headers,
		method:'POST',
		data:{"data":prams}
	})
}
/**门店列表 */
export function StoreList(prams){
	return request({
		type: 'sc',
		url:'/shop/getStoreList',
		headers:headers,
		method:'POST',
		data:{"data":prams}
	})
}

/**通过城市查经纬度*/
export function chxy(data, _t) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: "https://restapi.amap.com/v3/geocode/geo",
      method: "GET",
      data:{
        key:'1c33a1fc5287a0ab5735484c6be70522',
        address:data
      },
      success: resolve,
      fail: reject
    })
  });
  
}
/**通过经纬度，查城市*/
export function chqu(data){
  return new Promise((resolve, reject) => {
    uni.request({
      url: "https://restapi.amap.com/v3/geocode/regeo",
      method: "GET",
      data:{
        key:'1c33a1fc5287a0ab5735484c6be70522',
        location: data,
      },
      success: resolve,
      fail: reject
    })
  })
}